﻿ChooseObjects by Jesse McGrew begins here.

Section A1 - Turning ChooseObjects into an activity 


[This activity needs (future action) because the action at this point 
is stored in the I6 variable 'action_to_be', not just 'action'.] 
Choosing ambiguous objects (future action) is an activity. 


Chosen flag is a number that varies. Next parsing score is a number 
that varies. 


After deciding the scope of the player (this is the reset ChooseObjects 
variables rule): 
        change chosen flag to 0; 
        change next parsing score to 100. 


A thing has a number called parsing score. The parsing score of a thing 
is usually 0. Parsing score translates into Inform as "cobj_score". 


To try (obj - object): 
        change the parsing score of obj to next parsing score; 
        decrease next parsing score by 1. 


To try (OS - object-specification-unsub) in turn: 
        (- CobjTryMulti({P#OS}, 0); -). 


To try (OS - object-specification-unsub) [equally by default]: 
        (- CobjTryMulti({P#OS}, 1); -). 


To try (OS - object-specification-unsub) equally: 
        (- CobjTryMulti({P#OS}, 1); -). 


Include (- Replace ChooseObjects; -) before the library. 


Include (- 
[ ChooseObjects obj code  i; 
        ! codes 0 and 1 should be handled by the 
        ! "deciding whether all includes something" activity 
        if (code < 2) rfalse; 
        if ((+chosen flag+) == 0) { 
                (+chosen flag+) = 1; 
                for ( i=0: i<number_matched: i++ ) { 
                        if (match_list-->i provides cobj_score) 
                                (match_list-->i).cobj_score = 0; 
                } 
                CarryOutActivity( (+choosing ambiguous objects+), obj); 
        } 
        if (obj provides cobj_score) return obj.cobj_score; 
        else return 0; 
]; 


[ CobjTryMulti filter eq  i x; 
        if (filter==0) rfalse; 
        for ( i=0: i<number_matched: i++ ) { 
                x = match_list-->i; 
                if (x provides cobj_score && x.cobj_score == 0 && filter(x)) { 
                        if (eq==0 && i>0) (+next parsing score+)--; 
                        x.cobj_score = (+next parsing score+); 
                } 
        } 
        (+next parsing score+)--; 
]; 
-). 

ChooseObject ends here.

---- DOCUMENTATION ----

Here is a sample:

Green Room is a room. 


An artwork is a kind of thing. The green painting and the green 
sculpture are artworks in the green room. 


Rule for writing a paragraph about an artwork: say "Your eyes are drawn 
[if more than one artwork is in the location]equally [end if]to [a list 
of artworks in the location]." 


A green suitcase is here. "A green suitcase is here, and whatever's 
inside, you just know you want it." 
A green emerald is here. "A green emerald is here, and it must be worth 
a fortune!" 


A treasure is a kind of thing. The suitcase and the emerald are 
treasures. 


A green cookie is here. It is edible. "Your mouth waters at the scent 
of a green cookie." 
A green apple is here. It is edible. 


Rule for choosing ambiguous objects when taking: 
        try treasures which are not carried in turn. 


Rule for choosing ambiguous objects when eating: 
        try the cookie; 
        try the apple. 


Rule for choosing ambiguous objects when examining: 
        try every artwork. 


Test me with "eat green / eat green / take green / take green / take 
sculpture / examine green / drop sculpture then take painting / examine 
green". 


